<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/view/commons/common.jsp" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>光蓝后台管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${ctx}/static/css/font.css">
    <link rel="stylesheet" href="${ctx}/static/css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="${ctx}/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${ctx}/static/js/xadmin.js"></script>
</head>
<body>
<!-- 中部开始 -->
<div class="wrapper">
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="content">
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form" action="/system/role/editRole" id="dataForm">
                <input type="hidden" name="editId" value="${role.id}">
                <div class="layui-form-item">
                    <label for="roleName" class="layui-form-label">
                        角色名
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="roleName" name="roleName" required lay-verify="required"
                               autocomplete="off" value="${role.roleName}" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn" id="formBtn" onclick="submitDataForm();">
                        保存
                    </button>
                </div>
            </form>
            <!-- 右侧内容框架，更改从这里结束 -->
        </div>
    </div>
    <!-- 右侧主体结束 -->
</div>
<!-- 中部结束 -->

<script type="application/javascript">

    function submitDataForm(){
        $.ajax({
            type:'post',
            data:{'editId':$('#editId').val(),
                'roleName':$('#roleName').val()
            },
            url:'/system/role/editRole',
            dataType:'json',
            success:function (data) {
                //添加数据成功，关闭弹出窗之前，刷新列表页面的数据
                parent.window.location.href="/system/role/index";
                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
            },
            error:function (error) {
                layer.msg(error.msg,{icon:1,time:1000})
            }
        });
    }
</script>
</body>
</html>